<?php

use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;
use Dcat\Admin\Grid\Filter;
use Dcat\Admin\Show;
use Dcat\Admin\Layout\Navbar;
use App\Models\AdminUser;


/**
 * Dcat-admin - admin builder based on Laravel.
 * @author jqh <https://github.com/jqhph>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 *
 * extend custom field:
 * Dcat\Admin\Form::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
 * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */


app('view')->prependNamespace('admin', resource_path('views/vendor/laravel-admin'));


Dcat\Admin\Admin::favicon('../../image/favicon.ico');

admin::js(['ftp/zh.js']);

Admin::script(
    <<<JS
    zh_tran('t')
JS
);

Admin::navbar(function (Navbar $navbar) {

    if (Admin::guard()->check()){
        $user = AdminUser::find(Admin::user()->id);
        if ($user->users_leader_id == 0){
            $res = '普通用户';
        }else{
            $res = $user->users_leader->leader;
        }

        $html = <<<EOT
            <a class="dropdown-toggle nav-link" style="margin-left:10px;" href="#" id="dropdown-flag" data-toggle="dropdown">
                用户等级:
                <span class="selected-language">$res</span>
            </a>
EOT;
        $navbar->left($html);
    }


    $navbar->right(view('member.checkout_lang.lang',['url'=>request()->getUri()])->render());
});


